package com.zytech.zspider.task.event;

import com.zytech.modules.lang.Requires;
import com.zytech.zspider.core.TaskDefinition;
import com.zytech.zspider.core.TaskResult;
import com.zytech.zspider.eventbus.Event;

/**
 * @author siuming
 */
public final class TaskEvents {

    /**
     * @param task
     * @return
     */
    public static Event newTaskAssembled(TaskDefinition task) {
        Requires.notNull(task, "task must not be null.");
        return new TaskAssembledEvent(task);
    }

    /**
     * @param task
     * @param reason
     * @return
     */
    public static Event newTaskFailed(TaskDefinition task, String reason) {
        Requires.notNull(task, "task must not be null.");
        return new TaskFailedEvent(task, reason);
    }

    /**
     * @param task
     * @param result
     * @return
     */
    public static Event newTaskSucceed(TaskDefinition task, TaskResult result) {
        Requires.notNull(task, "task must not be null.");
        Requires.notNull(result, "result must not be null.");
        return new TaskSucceedEvent(task, result);
    }

    private TaskEvents() {
    }
}
